﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SARControlLib;

namespace RadarSim
{
	public partial class Config:PageBase
	{
        List<TS201DataGridBean> l;
        TS201DataGridBean tsb = new TS201DataGridBean("a", "b", "c", "d", "e", true, "fff");
        TS201DataGridBean tsb2 = new TS201DataGridBean("a", "b", "c", "d", "e", false, "fff");
		public Config()
        {
            this.InitializeComponent();
            this.AdcGrid.Visibility = Visibility.Visible;
            DacGrid.Visibility = Visibility.Collapsed;
            FpgaGrid.Visibility = Visibility.Collapsed;
            TimerGrid.Visibility = Visibility.Collapsed;
            Ts201Grid.Visibility = Visibility.Collapsed;
            C6455Grid.Visibility = Visibility.Collapsed;
            RemoteConfig.Visibility = Visibility.Collapsed;


            // 在此点之下插入创建对象所需的代码。


            {
                DataGridTextColumn dtc0 = new DataGridTextColumn();
                dtc0.Header = "延时";
                Binding b0 = new Binding();
                b0.Path = new PropertyPath("Head0");
                b0.Mode = BindingMode.TwoWay;
                b0.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                dtc0.Binding = b0;

                DataGridTextColumn dtc1 = new DataGridTextColumn();
                dtc1.Header = "脉宽";
                Binding b1 = new Binding();
                b1.Path = new PropertyPath("Head1");
                b1.Mode = BindingMode.TwoWay;
                b1.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                dtc1.Binding = b1;

                this.timeTable1.SARnterDataGrid.Columns.Add(dtc0);
                this.timeTable1.SARnterDataGrid.Columns.Add(dtc1);
                this.timeTable1.DataGridTitle = "";
            }
            {
                DataGridTextColumn dtc0 = new DataGridTextColumn();
                dtc0.Header = "延时";
                Binding b0 = new Binding();
                b0.Path = new PropertyPath("Head0");
                b0.Mode = BindingMode.TwoWay;
                b0.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                dtc0.Binding = b0;

                DataGridTextColumn dtc1 = new DataGridTextColumn();
                dtc1.Header = "脉宽";
                Binding b1 = new Binding();
                b1.Path = new PropertyPath("Head1");
                b1.Mode = BindingMode.TwoWay;
                b1.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                dtc1.Binding = b1;

                this.timeTable2.SARnterDataGrid.Columns.Add(dtc0);
                this.timeTable2.SARnterDataGrid.Columns.Add(dtc1);
                this.timeTable2.DataGridTitle = "";
            }

            {
                DataGridTextColumn dtc0 = new DataGridTextColumn();
                dtc0.Header = "延时";
                Binding b0 = new Binding();
                b0.Path = new PropertyPath("Head0");
                b0.Mode = BindingMode.TwoWay;
                b0.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                dtc0.Binding = b0;

                DataGridTextColumn dtc1 = new DataGridTextColumn();
                dtc1.Header = "脉宽";
                Binding b1 = new Binding();
                b1.Path = new PropertyPath("Head1");
                b1.Mode = BindingMode.TwoWay;
                b1.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                dtc1.Binding = b1;
                this.timeTable3.SARnterDataGrid.Columns.Add(dtc0);
                this.timeTable3.SARnterDataGrid.Columns.Add(dtc1);
                this.timeTable3.DataGridTitle = "";
            }

            DataGridTextColumn rdtc0 = new DataGridTextColumn();
            rdtc0.Header = ".c";
            Binding rb0 = new Binding();
            rb0.Mode = BindingMode.TwoWay;
            rb0.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            rb0.Path = new PropertyPath("Head0");
            rdtc0.Binding = rb0;

            DataGridTextColumn rdtc1 = new DataGridTextColumn();
            rdtc1.Header = "DeviceID";
            Binding rb1 = new Binding();
            rb1.Mode = BindingMode.TwoWay;
            rb1.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            rb1.Path = new PropertyPath("Head1");
            rdtc1.Binding = rb1;

            DataGridTextColumn rdtc2 = new DataGridTextColumn();
            rdtc2.Header = "BoardID";
            Binding rb2 = new Binding();
            rb2.Mode = BindingMode.TwoWay;
            rb2.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            rb2.Path = new PropertyPath("Head2");
            rdtc2.Binding = rb2;

            DataGridTextColumn rdtc3 = new DataGridTextColumn();
            rdtc3.Header = "NodelID";
            Binding rb3 = new Binding();
            rb3.Mode = BindingMode.TwoWay;
            rb3.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            rb3.Path = new PropertyPath("Head3");
            rdtc3.Binding = rb3;

            DataGridTextColumn rdtc4 = new DataGridTextColumn();
            rdtc4.Header = "DSPID";
            Binding rb4 = new Binding();
            rb4.Mode = BindingMode.TwoWay;
            rb4.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            rb4.Path = new PropertyPath("Head4");
            rdtc4.Binding = rb4;

            //DataGridTextColumn rdtc6 = new DataGridTextColumn();
            //rdtc6.Header = "LDR PATH";
            //Binding rb6 = new Binding();
            //rb6.Path = new PropertyPath("Head5");
            //rdtc6.Binding = rb6;


            DataGridTemplateColumn rdtc6 = new DataGridTemplateColumn();
            rdtc6.Header = "LDR PATH";
            DataTemplate dt1 = new DataTemplate();
            FrameworkElementFactory fef1 = new FrameworkElementFactory(typeof(SARFileDialog));
            Binding rb6 = new Binding();
            rb6.Mode = BindingMode.TwoWay;
            rb6.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            rb6.Path = new PropertyPath("Head6");
            fef1.SetBinding(SARFileDialog.FilePath,rb6);
                //(sar.TextProperty, new Binding("Head6"));
            dt1.VisualTree = fef1;
            rdtc6.CellTemplate = dt1;

            DataGridCheckBoxColumn rdtc5 = new DataGridCheckBoxColumn();
            rdtc5.Header = "STATE";
            Binding rb5 = new Binding();
            rb5.Mode = BindingMode.TwoWay;
            rb5.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            rb5.Path = new PropertyPath("Head5");
            rdtc5.Binding = rb5;

            this.ts201DataTable.SARnterDataGrid.Columns.Add(rdtc0);
            this.ts201DataTable.SARnterDataGrid.Columns.Add(rdtc1);
            this.ts201DataTable.SARnterDataGrid.Columns.Add(rdtc2);
            this.ts201DataTable.SARnterDataGrid.Columns.Add(rdtc3);
            this.ts201DataTable.SARnterDataGrid.Columns.Add(rdtc4);
            this.ts201DataTable.SARnterDataGrid.Columns.Add(rdtc5);
            this.ts201DataTable.SARnterDataGrid.Columns.Add(rdtc6);
            this.ts201DataTable.DataGridTitle = "";


            l = new List<TS201DataGridBean>();
            tsb.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(tsb_PropertyChanged);
            l.Add(tsb);
            l.Add(tsb2);
            this.ts201DataTable.SARItemsSource = l;
            //this.ts201DataTable.ts201BeanListPro = l;

            //tsb.Head6 = "d:";


        }

        void tsb_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            //throw new NotImplementedException();
            ts201DataTable.SARItemsSource = l;
        }
        public bool AppConfigClick()
        {
            return true;
        }
        public bool ControlArgsClick()
        {
            return true;
        }
        public bool InitArgsClick()
        {
            return true;
        }
        public bool RealTimeInfoClick()
        {
            return true;
        }

        private void configBar_SARMenuClick(int menuItemIndex)
        {
            if (menuItemIndex == 0)
            {
                this.AdcGrid.Visibility = Visibility.Visible;
                DacGrid.Visibility = Visibility.Collapsed;
                FpgaGrid.Visibility = Visibility.Collapsed;
                TimerGrid.Visibility = Visibility.Collapsed;
                Ts201Grid.Visibility = Visibility.Collapsed;
                C6455Grid.Visibility = Visibility.Collapsed;
                RemoteConfig.Visibility = Visibility.Collapsed;
            }else if (menuItemIndex == 1)
            {
                this.AdcGrid.Visibility = Visibility.Collapsed;
                DacGrid.Visibility = Visibility.Visible;
                FpgaGrid.Visibility = Visibility.Collapsed;
                TimerGrid.Visibility = Visibility.Collapsed;
                Ts201Grid.Visibility = Visibility.Collapsed;
                C6455Grid.Visibility = Visibility.Collapsed;
                RemoteConfig.Visibility = Visibility.Collapsed;
            }
            else if (menuItemIndex == 2)
            {
                this.AdcGrid.Visibility = Visibility.Collapsed;
                DacGrid.Visibility = Visibility.Collapsed;
                FpgaGrid.Visibility = Visibility.Visible;
                TimerGrid.Visibility = Visibility.Collapsed;
                Ts201Grid.Visibility = Visibility.Collapsed;
                C6455Grid.Visibility = Visibility.Collapsed;
                RemoteConfig.Visibility = Visibility.Collapsed;
            }
            else if (menuItemIndex == 3)
            {
                this.AdcGrid.Visibility = Visibility.Collapsed;
                DacGrid.Visibility = Visibility.Collapsed;
                FpgaGrid.Visibility = Visibility.Collapsed;
                TimerGrid.Visibility = Visibility.Visible;
                Ts201Grid.Visibility = Visibility.Collapsed;
                C6455Grid.Visibility = Visibility.Collapsed;
                RemoteConfig.Visibility = Visibility.Collapsed;
            }
            else if (menuItemIndex == 4)
            {
                this.AdcGrid.Visibility = Visibility.Collapsed;
                DacGrid.Visibility = Visibility.Collapsed;
                FpgaGrid.Visibility = Visibility.Collapsed;
                TimerGrid.Visibility = Visibility.Collapsed;
                Ts201Grid.Visibility = Visibility.Visible;
                C6455Grid.Visibility = Visibility.Collapsed;
                RemoteConfig.Visibility = Visibility.Collapsed;
            }
            else if(menuItemIndex==5)
            {
                this.AdcGrid.Visibility = Visibility.Collapsed;
                DacGrid.Visibility = Visibility.Collapsed;
                FpgaGrid.Visibility = Visibility.Collapsed;
                TimerGrid.Visibility = Visibility.Collapsed;
                Ts201Grid.Visibility = Visibility.Collapsed;
                C6455Grid.Visibility = Visibility.Visible;
                RemoteConfig.Visibility = Visibility.Collapsed;
            }
            else if (menuItemIndex == 6)
            {
                this.AdcGrid.Visibility = Visibility.Collapsed;
                DacGrid.Visibility = Visibility.Collapsed;
                FpgaGrid.Visibility = Visibility.Collapsed;
                TimerGrid.Visibility = Visibility.Collapsed;
                Ts201Grid.Visibility = Visibility.Collapsed;
                C6455Grid.Visibility = Visibility.Collapsed;
                RemoteConfig.Visibility = Visibility.Visible;
            }
        }

        private void SAR_BigButton_SARBigBtnClick(object sender, MouseButtonEventArgs e)
        {
            ADCArgConfig adcDialog = new ADCArgConfig();
            adcDialog.ShowDialog();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            List<TS201DataGridBean> ll = (List<TS201DataGridBean>)ts201DataTable.SARItemsSource;
            //string s = ts201DataTable.Getres();
            int i = l.Count;

            

        }

	}
}